// pages/systemSetting/systemSetting.js
import jumpUrl from '../../../utils/jumpUrl'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    selectInfo: [
      // {
      //     haveIcon: true,
      //     haveImg: false,
      //     url: '/pagePersonalCenter/pages/person-systemSetting/systemSetting',
      //     name: '',
      //     iconclass: '',
      //     imgUrl: ''
      //     type:""
      //   },
      {
        haveIcon: true,
        name: '清空本地缓存',
        iconclass: 'poea-clear',
        selectType: 'clear'
      },
      {
        haveIcon: true,
        url: '/pageAdmin/pages/login/admin-login',
        name: '进入后台管理',
        iconclass: 'poea-backstage',
        selectType: 'Admin',
        type: 'relaunch'
      }
    ]
  },

  // 返回
  onNavBackTap() {
    wx.navigateBack({})
  },

  // 点击选择列表的回调
  tapSectionList(e) {
    console.log(e)
    const type = e.currentTarget.id
    const selectType = e.currentTarget.dataset.selecttype
    console.log(selectType)
    if (selectType === 'Admin') {
      jumpUrl.toUrl(e, this)
    }
    if (selectType === 'clear') {
      wx.showModal({
        title: '是否清除缓存数据',
        content: '',
        complete: res => {
          if (res.cancel) {
            console.log('点击取消')
          }
          if (res.confirm) {
            wx.clearStorage().then(() => {
              wx.showToast({
                title: '清除缓存成功',
                icon: 'success',
                duration: 2000
              })
            })
          }
        }
      })
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {}
})
